//
//  LBViewController.m
//  LBPointLeftBannerView
//
//  Created by liubo on 09/24/2023.
//  Copyright (c) 2023 liubo. All rights reserved.
//

#import "LBViewController.h"
#import <LBPointLeftBannerView/LBPointLeftBannerView.h>
#import "LBViewCell.h"

@interface LBViewController ()

@property (nonatomic, strong) LBPointLeftBannerView *loopView;

@end

@implementation LBViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self.view addSubview:self.loopView];
    [self.loopView reloadData];
	// Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - LBMiddleExpandViewDelegate, LBMiddleExpandViewDataSource

- (NSInteger)numberOfCellsInCycleScrollView:(LBPointLeftBannerView *)cycleScrollView {
    return 6;
}

- (LBPointLeftBannerViewBaseCell *)cycleScrollView:(LBPointLeftBannerView *)cycleScrollView cellForViewAtIndex:(NSInteger)index {
    LBViewCell *cell = [cycleScrollView dequeueReusableCellWithIdentifier:@"333"];
    if (!cell) {
        cell = [LBViewCell new];
        cell.layer.cornerRadius = 10;
        cell.layer.masksToBounds = YES;
        cell.imageView.contentMode = UIViewContentModeScaleAspectFill;
    }
    cell.imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"%ld",index + 1]];
    return cell;
}

- (CGSize)sizeForCellInCycleScrollView:(LBPointLeftBannerView *)cycleScrollView {
    return CGSizeMake(300, 150);
}

- (void)cycleScrollView:(LBPointLeftBannerView *)cycleScrollView didScrollCellToIndex:(NSInteger)index {
    if (cycleScrollView.scrollView.isTracking) return;

}



- (LBPointLeftBannerView *)loopView {
    if (!_loopView) {
        _loopView = [LBPointLeftBannerView new];
        _loopView.dataSource = self;
        _loopView.delegate = self;
        [_loopView registerClass:[LBViewCell class] forViewReuseIdentifier:@"333"];
//        _cycleScrollView.isAutoScroll = NO;
        _loopView.isInfiniteLoop = NO;
        _loopView.leftMargin = 20;
        _loopView.itemSpace = 10;
        _loopView.topBottomMargin = 40;
        _loopView.frame = CGRectMake(0, 100, CGRectGetWidth(self.view.bounds), 150);
    }
    return _loopView;
}


@end
